from lxml import etree
# parser=etree.HTMLParser(encoding='utf-8')
# html=etree.parse("tencent.html",parser=parser)
# #1.获取所有的tr标签 //tr
# trs=html.xpath("//tr")
# for tr in trs:
#     print(tr)
#trs=htm;.xpath("//tr[position()>1]")
#https://www.dytt8.net/html/gndy/china/index.html
import requests
import parsel
headers = {
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
    'cookie':'UM_distinctid=1716941d927652-0fb3ea40be025c-335e4e71-144000-1716941d929197; __login_his_sync=0; tourist_expires=1; Hm_lvt_407473d433e871de861cf818aa1405a1=1586608862; _GUID=d8eec002-35da-1ad7-ac12-9ca1c3cb4309; CNZZDATA1261814609=674853875-1586608471-https%253A%252F%252Fwww.mkzhan.com%252F%7C1586608471; readMode=scroll; CNZZDATA1262045698=1069876723-1586605088-https%253A%252F%252Fwww.baidu.com%252F%7C1586607119; redirect_url=%2F211692%2F; Hm_lpvt_407473d433e871de861cf818aa1405a1=1586610847; cn_1262045698_dplus=%7B%22distinct_id%22%3A%20%221716941d927652-0fb3ea40be025c-335e4e71-144000-1716941d929197%22%2C%22%24_sessionid%22%3A%200%2C%22%24_sessionTime%22%3A%201586610857%2C%22%24dp%22%3A%200%2C%22%24_sessionPVTime%22%3A%201586610857%7D',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
    'referer': 'https://www.mkzhan.com/search/?keyword=%E6%96%97%E7%BD%97%E5%A4%A7%E9%99%86'
}
url='https://movie.douban.com/'
response=requests.get(url,headers=headers,timeout=30)
response.encoding=response.apparent_encoding
text=response.content.decode()
html=etree.HTML(text)
# ul=html.xpath('//div[@class="slide-wrapper"]/div[1<position()<7]')
# print(ul)
parse=parsel.Selector(text)
ul=parse.xpath('//div[@class="slide-wrapper"]').extract()
print(ul)
# print(html)

